﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
namespace MyWeb.Data
{
	public class tb_UserDAL : SqlDataProvider
	{

		#region[tb_User_GetbyAll]
		public DataTable tb_User_GetByAll()
		{
			using (var cmd = new SqlCommand("sp_tb_User_GetByAll", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tb_User_GetbyId]
		public DataTable tb_User_GetById(tb_UserInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tb_User_GetById", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Username", Data.Username));
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion

		#region[tb_User_GetbyTop]
		public DataTable tb_User_GetByTop(string Top, string Where, string Order)
		{
			using (var cmd = new SqlCommand("sp_tb_User_GetByTop", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				cmd.Parameters.Add(new SqlParameter("@Top",Top));
				cmd.Parameters.Add(new SqlParameter("@Where",Where));
				cmd.Parameters.Add(new SqlParameter("@Order",Order));
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tb_User_Insert]
		public void tb_User_Insert(tb_UserInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tb_User_Insert", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Username", Data.Username));
				cmd.Parameters.Add(new SqlParameter("@Password", Data.Password));
				cmd.Parameters.Add(new SqlParameter("@Address", Data.Address));
				cmd.Parameters.Add(new SqlParameter("@Phone", Data.Phone));
				cmd.Parameters.Add(new SqlParameter("@Gender", Data.Gender));
				cmd.Parameters.Add(new SqlParameter("@Status", Data.Status));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
		#region[tb_User_Update]
		public void tb_User_Update(tb_UserInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tb_User_Update", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Username", Data.Username));
				cmd.Parameters.Add(new SqlParameter("@Password", Data.Password));
				cmd.Parameters.Add(new SqlParameter("@Address", Data.Address));
				cmd.Parameters.Add(new SqlParameter("@Phone", Data.Phone));
				cmd.Parameters.Add(new SqlParameter("@Gender", Data.Gender));
				cmd.Parameters.Add(new SqlParameter("@Status", Data.Status));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
		#region[tb_User_Delete]
		public void tb_User_Delete(string Data)
		{
			using (var cmd = new SqlCommand("sp_tb_User_Delete", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Username", Data));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
	}
}